package bairui.international.model.domain.jpa;

/**
 *
 * @see TB_WinPrize 中奖
 *
 */
public class TestData_TB_WinPrize
{

	private final static org.apache.commons.text.RandomStringGenerator Generator = new org.apache.commons.text.RandomStringGenerator.Builder().withinRange(new char[][]{{'a','z'}, {'A','Z'}, {'0','9'}}).build();

	@SuppressWarnings({ "unchecked", "rawtypes" })
	@org.springframework.transaction.annotation.Transactional(rollbackFor=java.lang.Throwable.class)
	public static TB_WinPrize saveMust(
		org.springframework.context.ApplicationContext context,
		bairui.international.model.domain.jpa.id.ID_WinPrize id,
	bairui.international.model.domain.jpa.TB_PrizeItem prizeItem
	){
		org.springframework.data.jpa.repository.JpaRepository repository = (org.springframework.data.jpa.repository.JpaRepository)context.getBean("repository_WinPrize");
		return (TB_WinPrize)repository.save(newMust(
				id,
				prizeItem
			));
	}
	
	public static TB_WinPrize newMust(
		bairui.international.model.domain.jpa.id.ID_WinPrize id,
	bairui.international.model.domain.jpa.TB_PrizeItem prizeItem
	){
		return new TB_WinPrize(new TB_WinPrize.MustProperties() {
			@Override public bairui.international.model.domain.jpa.id.ID_WinPrize getId(){
				return id;
			}
			/** 奖品 */
			@Override public bairui.international.model.domain.jpa.TB_PrizeItem getPrizeItem(){
				return prizeItem;
			}
			/** 非奖品标志 */
			@Override public Boolean getNoPrizeFlag(){
				return new java.util.Random().nextBoolean();
			}
			/** 核销标志 */
			@Override public Boolean getFinishFlag(){
				return new java.util.Random().nextBoolean();
			}
		});
	}
	

	@SuppressWarnings({ "unchecked", "rawtypes" })
	@org.springframework.transaction.annotation.Transactional(rollbackFor=java.lang.Throwable.class)
	public static TB_WinPrize saveAll(
		org.springframework.context.ApplicationContext context,
		bairui.international.model.domain.jpa.id.ID_WinPrize id,
	bairui.international.model.domain.jpa.TB_PrizeItem prizeItem
	,bairui.international.model.domain.jpa.TB_Admin finishor
	){
		org.springframework.data.jpa.repository.JpaRepository repository = (org.springframework.data.jpa.repository.JpaRepository)context.getBean("repository_WinPrize");
		return (TB_WinPrize)repository.save(newAll(
				id,
				prizeItem
				,finishor
			));
	}
	
	public static TB_WinPrize newAll(
		bairui.international.model.domain.jpa.id.ID_WinPrize id,
	bairui.international.model.domain.jpa.TB_PrizeItem prizeItem
	,bairui.international.model.domain.jpa.TB_Admin finishor
	){
		return new TB_WinPrize(
			new TB_WinPrize.MustProperties() {
				@Override public bairui.international.model.domain.jpa.id.ID_WinPrize getId(){
					return id;
				}
				/** 奖品 */
				@Override public bairui.international.model.domain.jpa.TB_PrizeItem getPrizeItem(){
					return prizeItem;
				}
				/** 非奖品标志 */
				@Override public Boolean getNoPrizeFlag(){
					return new java.util.Random().nextBoolean();
				}
				/** 核销标志 */
				@Override public Boolean getFinishFlag(){
					return new java.util.Random().nextBoolean();
				}
			},
			new TB_WinPrize.OptionalSingleProperties() {
				/** 电话 */
				@Override public String getPhone(){
					return Generator.generate(0, 20);
				}
				/** 中奖概率% */
				@Override public Double getRate(){
					return com.sh_lianjing.test.random.Util_GenerateRandom.doubleRandom(0, 100);
				}
				/** 名称 */
				@Override public String getPrizeName(){
					return Generator.generate(0, 30);
				}
				/** 图片 */
				@Override public String getImgUrl(){
					return Generator.generate(0, 100);
				}
				/** 用户真实姓名 */
				@Override public String getRealName(){
					return Generator.generate(0, 100);
				}
				/** 用户昵称 */
				@Override public String getNickName(){
					return Generator.generate(0, 100);
				}
				/** 用户类型 */
				@Override public bairui.international.model.type.Type_User getUserType(){
					return bairui.international.model.type.Type_User.General;
				}
				/** 核销时间 */
				@Override public java.util.Date getFinishTime(){
					return new java.util.Date();
				}
				/** 核销者 */
				@Override public bairui.international.model.domain.jpa.TB_Admin getFinishor(){
					return finishor;
				}
			}
		);
	}
	

}
